package com.tianbo.service.imp;

import com.tianbo.common.ModelAndPage;
import com.tianbo.mapper.TOlapXmldocMapper;
import com.tianbo.model.TOlapXmldoc;
import com.tianbo.model.TOlapXmldocExample;
import com.tianbo.service.OlapXmldocService;
import com.tianbo.util.dao.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by Mr.Xu on 2017/9/14.
 */
@Service
public class OlapXmldocImpl implements OlapXmldocService {
    @Autowired
    private TOlapXmldocMapper olapXmldocMapper;
    public List<TOlapXmldoc> findXmldoc()throws Exception{
        TOlapXmldocExample olapxmldoc=new TOlapXmldocExample();
        List<TOlapXmldoc> olapXmldocList=olapXmldocMapper.selectByExample(olapxmldoc);
        return olapXmldocList;
    }
    public ModelAndPage findXmldoc(int start, int pagelenth)throws Exception{
        TOlapXmldocExample tOlapXmldocExample=new TOlapXmldocExample();
        Page page=new Page(start,pagelenth);
        tOlapXmldocExample.setPage(page);
        int count=olapXmldocMapper.countByExample(tOlapXmldocExample);
        page.setCount(count);
        List<TOlapXmldoc> tOlapXmldocList=olapXmldocMapper.selectByExample(tOlapXmldocExample);
        ModelAndPage<TOlapXmldoc> modelAndPage=new ModelAndPage<TOlapXmldoc>(tOlapXmldocList,page);
        return modelAndPage;
    }
    public void addXmldoc(TOlapXmldoc olapXmldoc){olapXmldocMapper.insert(olapXmldoc);}
    public TOlapXmldoc findByid(BigDecimal docid) throws Exception{
        TOlapXmldoc olapXmldoc=new TOlapXmldoc();
        olapXmldoc=olapXmldocMapper.selectByPrimaryKey(docid);
        return  olapXmldoc;
    }
    public void updateXmldoc(TOlapXmldoc olapXmldoc){olapXmldocMapper.updateByPrimaryKey(olapXmldoc);}
    public int deleteXmldoc(BigDecimal docid){olapXmldocMapper.deleteByPrimaryKey(docid); return 1;}
}
